<template>
	<div>
		<Button type='success' v-for='(item,index) in arr' @click='handClick(index)' :key='`btn_${index}`'>{{item}}</Button>
		<br />
		<Button type='primary' @click.native='send("GPS")'>发送位置</Button>
		<Button type='primary' @click.native='send("image")'>发送图片</Button>
		<Button type='primary' @click.native='send("file")'>发送文件</Button>
		<Button type='primary' @click.native='send("audio")'>发送语音</Button>
		<Button type='primary' @click.native='send("text")'>发送文本</Button>
		<br />
		<Button type='primary' @click.native='group("GPS")'>群发送位置</Button>
		<Button type='primary' @click.native='group("iamge")'>群发送图片</Button>
		<Button type='primary' @click.native='group("file")'>群发送文件</Button>
		<Button type='primary' @click.native='group("audio")'>群发送语音</Button>
		<Button type='primary' @click.native='group("text")'>群发送文本</Button>
		<audio :src="audio" controls="controls"></audio>
		<audio src="http://192.168.1.41:12000/file/file/2018/09/12/92829d099b6e41db883cb19c9048f5d2.mp3" controls="controls"></audio>
		<!--<embed src="http://192.168.1.41:12000/file/file/2018/09/12/92829d099b6e41db883cb19c9048f5d2.mp3" type="" width="300px" height="200px" autoplay='false'/>-->
	</div>
</template>

<script>
import {universal_axios} from '@/api/test.js'
	export default {
		data() {
			return {
				arr:['获取置顶接口','添加置顶接口','删除置顶接口','修改权限接口','获取用户详情接口','登出接口','获取常用联系人接口','添加常用联系人接口','删除常用联系人接口','更改密码接口','获取组织结构接口','组织用户名搜索接口','建群接口','获取用户群列表接口','获取群详情接口','获取全部群数据接口','添加组员接口','修改群权限接口','修改群详情接口','删除群成员接口','解除群接口','获取群成员接口','上传图片接口','上传音频、文件接口','下载音频、文件接口','下载超小图接口','下载小图接口','下载原图接口','上传头像接口','下载头像接口'],
				add:['user/getSetaTopList.do','user/addSetaTop.do','user/delSetaTop.do','user/updatePower.do','user/getUserInfo.do','user/loginOut.do','user/categoryMemberList.do','user/addUserCategoryMember.do','user/deleteUserCategoryMember.do','user/updatePassword.do','user/getGroup.do','user/getUserList.do','group/addGroup.do','group/getGroupByUserId.do','group/getGroupById.do','group/getGroupAndUsersById.do','group/addGroupMembers.do','group/editMemberPosition.do','group/editGroup.do','group/delMember.do','group/delGroup.do','group/getListByGroupId.do','api/v1/oim/image/upload.do','api/v1/oim/file/upload.do','api/v1/oim/file/download.do','api/v1/oim/image/downloadmini.do','api/v1/oim/image/downloadsmall.do','api/v1/oim/image/download.do','api/v1/oim/head/user/upload.do','api/v1/oim/head/user/download.do'],
				audio:"http://192.168.1.41:12000/file/file/2018/09/12/92829d099b6e41db883cb19c9048f5d2.mp3"
			}
		},
		computed: {
			myInfo() {
				return this.$store.state.myInfo
			},
			toInfo() {
				return this.$store.state.toInfo
			},
			ws() {
				return this.$store.state.ws
			}
		},
		methods: {
			handClick(index){
				let data = {}
				data = index == 0?{userid:this.myInfo.id,ltype:'pc'}:index==1?{userid:this.myInfo.id,type:'1',objectId:this.toInfo.id,sort:'0',ltype:'pc'}:index==2?{userid:this.myInfo.id,type:'2',objectId:this.toInfo.id,ltype:'pc'}:{fuserid:this.myInfo.id,tuserid:this.toInfo.id,radioOf:'1',groupOf:'1',ltype:'pc'}
				universal_axios(this.add[index],data).then(info=>{
					console.log(info)
					console.log('-------------------------')
				}).catch(error =>{
					console.log('error',error)
				})
			},
			send(info) {
				let _this = this
				if(info == 'GPS') {
					this.$router.push({
						path:"/iframe"
					})
				} else if(info == 'image') {

				} else if(info == 'file') {

				} else if(info == 'audio') {

				} else {
					let messageKey = _this.$func.uuid()
					let newTime = new Date().getTime()
					let jsonArray = JSON.stringify({
						head: {
							key: messageKey,
							name: "",
							action: "1.500",
							method: "1.1.1001",
							version: "1",
							time: newTime
						},
						body: {
							messageKey: messageKey,
							sendUserId: _this.myInfo.id,
							receiveUserId: _this.toInfo.id,
							content: {
								font: {
									underline: false,
									bold: false,
									italic: false,
									color: "000000",
									name: "Microsoft YaHei",
									size: 14
								},
								sections: [{
									items: [{
										type: "text",
										value: JSON.stringify({
											text: "呵呵呵",
											sendName: _this.myInfo.name,
											receiveName: _this.toInfo.name
										})
									}]
								}],
								timestamp: newTime
							}
						}
					})
					//					let jsonArray = {
					//						"head": {
					//							"key": messageKey,
					//							"name": "",
					//							"action": "1.500",
					//							"method": "1.1.1001",
					//							"version": "1",
					//							"time": newTime
					//						},
					//						"body": {
					//							"sendUserId": _this.myInfo.id,
					//							"messageKey": messageKey,
					//							"receiveUserId": _this.toInfo.id,
					//							"content": {
					//								"font": {
					//									"underline": false,
					//									"bold": false,
					//									"italic": false,
					//									"color": "000000",
					//									"name": "Microsoft YaHei",
					//									"size": 14
					//								},
					//								"sections": [{
					//									"items": [{
					//										"type": "text",
					//										"value": "{\"text\":\"风格呵呵\",\"sendName\":\"曹昊\",\"receiveName\":\"乐声彬\"}"
					//									}]
					//								}],
					//								"timestamp": newTime
					//							}
					//						}
					//					}
					console.log(jsonArray)
					this.ws.send(jsonArray)
				}
			},
			group(info) {
				if(info == 'GPS') {

				} else if(info == 'image') {

				} else if(info == 'file') {

				} else if(info == 'audio') {

				} else {

				}
			}
		},
		mounted(){
			this.audio = "http://192.168.1.41:12000/file/file/2018/09/06/b0d6b4cf19e0408ebbfbe3bb8604e460.mp3"
//			var media = new Audio()
//			media.src = "C:/Users/Administrator/Desktop/%E5%8D%B3%E6%97%B6%E9%80%9A%E8%AE%AF/File/01003247/f0f983f712104757ac9235f123c2580b.mp3"
//			console.log(media)
		},
		created() {
			let arr = [{a:1},{b:2},"3"]
			console.log(typeof(arr[0]))
			console.log(typeof(arr[2]))
		}
	}
</script>

<style>

</style>